判断单调性  贪心

class Solution {
public:
    int wiggleMaxLength(vector<int>& nums) {
        int left=0,right=0,n=nums.size();
        size_t ret=0;
        if(n<2) return n;
        for(int i=0;i<n-1;i++)
        {
            right=nums[i]-nums[i+1];
            if(right==0) continue;
            if(left*right<=0) ++ret;
            left=right;
        }
        return ret+1;

    }
};